const DB = require('../../../utils/db')
// 引入jwt token工具
const JwtUtil = require('../../../utils/jwt')
/**
 * GET
 * 获取当前用户帖子总数
 */
module.exports = async (ctx) => {
  // 获取token
  
  let token = ctx.request.header.authorization

  let jwt = new JwtUtil(token)
  // 用token获取到userid
  let userid = jwt.verifyToken()
  
  const res = await DB.query(
    `select count(0) from my_app.dynamic  where userid = '${userid}'`
  )
  ctx.body = {
    code: 0,
    data: { ...res[0]},
  }
}
